package com.ruoyi.wx.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wx.domain.ACat;
import com.ruoyi.wx.service.IACatService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 猫咪图鉴Controller
 * 
 * @author pan
 * @date 2022-10-01
 */
@RestController
@RequestMapping("/wx/wxcatMessage")
public class ACatController extends BaseController
{
    @Autowired
    private IACatService aCatService;

    /**
     * 查询猫咪图鉴列表
     */
    @PreAuthorize("@ss.hasPermi('wx:wxcatMessage:list')")
    @GetMapping("/list")
    public TableDataInfo list(ACat aCat)
    {
        startPage();
        List<ACat> list = aCatService.selectACatList(aCat);
        return getDataTable(list);
    }

    /**
     * 导出猫咪图鉴列表
     */
    @PreAuthorize("@ss.hasPermi('wx:wxcatMessage:export')")
    @Log(title = "猫咪图鉴", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ACat aCat)
    {
        List<ACat> list = aCatService.selectACatList(aCat);
        ExcelUtil<ACat> util = new ExcelUtil<ACat>(ACat.class);
        util.exportExcel(response, list, "猫咪图鉴数据");
    }

    /**
     * 获取猫咪图鉴详细信息
     */
    @PreAuthorize("@ss.hasPermi('wx:wxcatMessage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(aCatService.selectACatById(id));
    }

    /**
     * 新增猫咪图鉴
     */
    @PreAuthorize("@ss.hasPermi('wx:wxcatMessage:add')")
    @Log(title = "猫咪图鉴", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ACat aCat)
    {
        return toAjax(aCatService.insertACat(aCat));
    }

    /**
     * 修改猫咪图鉴
     */
    @PreAuthorize("@ss.hasPermi('wx:wxcatMessage:edit')")
    @Log(title = "猫咪图鉴", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ACat aCat)
    {
        return toAjax(aCatService.updateACat(aCat));
    }

    /**
     * 删除猫咪图鉴
     */
    @PreAuthorize("@ss.hasPermi('wx:wxcatMessage:remove')")
    @Log(title = "猫咪图鉴", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aCatService.deleteACatByIds(ids));
    }
}
